Here is a quick test suite to verify that things basically work. To create this test:
  1. Expand your project (Ejb3Tutorial2)
  2. Select the test source folder
  3. Right-click and select New:Class
  4. Enter dao.impl for the Package
  5. Enter CompanyDaoImplTest for the Class name
  6. Click Finish
  7. Enter the following class
  8. Once the class is saved and compiles, execute it (Right-click in the file, select Run As::JUnit Test

CompanyDaoImplTest.java
package dao.impl;
 
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
 
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
 
import util.JBossUtil;
import dao.CompanyDao;
import entity.Address;
import entity.Company;
import entity.Person;
 
public class CompanyDaoImplTest {
    private CompanyDao dao;
 
    @BeforeClass
    public static void setupJboss() throws Exception {
        JBossUtil.startDeployer();
    }
 
    @Before
    public void getCompanyDao() throws Exception {
        dao = JBossUtil.lookup(CompanyDao.class, "CompanyDao/local");
    }
 
    private Company createCompanyImpl() {
        final Address a = new Address("5080 Spectrum Drive", "Suite 700 West",
                "Addison", "TX", "75001");
        final Company c = new Company("Valtech", a);
        dao.createCompany(c);
        return c;
    }
 
    @Test
    public void createCompany() {
        final Company c = createCompanyImpl();
        assertEquals("Valtech", c.getName());
        assertNotNull(c.getId());
    }
 
    @Test
    public void hirePerson() {
        final Address a = new Address("5080 Spectrum Drive", "Suite 700 West",
                "Addison", "TX", "75001");
        final Person p = new Person("Brett", 'L', "Schuchert", a);
        final Company c = createCompanyImpl();
        c.hire(p);
        dao.update(c);
        final Company found = dao.find(c.getId());
        assertEquals(1, found.getEmployees().size());
    }
}